<template>
	<view class="wf-box" :style="{ paddingTop: totalheight }">
		<view class="head" :style="{ paddingTop: navBarHeight }">
			<view class="head-np">
				<view class="tab">
					<view class="tab_item" v-for="(item,i) in list" :class="tabIndex==i? 'tab_sel':''" @click="tab(i)">
						<view class="t_i_text">{{item}}</view>
						<view :class="tabIndex==i?'t_i_line':'t_i_line2'"></view>
					</view>
				</view>
				<image src="@/static/img/square_icon1.png" class="add-icon" @click="my()" mode="widthFix"></image>
				<image src="@/static/img/square_icon2.png" class="add-icon" @click="add()" mode="widthFix"></image>
			</view>
		</view>

		<view class="main">
			<view class="item" v-if="true" v-for="(item,i) in firendCircleList" :key="i" @click="details(item)">
				<view class="item_top">
					<image :src="item.avatar" mode="aspectFill"></image>
					<view class="item_name">
						<view>
							{{ item.nikeName }}
							<!-- <image src="@/static/img/k_icon1.png" mode="widthFix"></image> -->
							<!-- <image src="@/static/img/k_icon2.png" mode="widthFix"></image> -->
						</view>
						<view>ID:{{ item.userId }}</view>
					</view>
					<view class="del">
						<view></view>
						<!-- <image src="@/static/img/k_icon3.png" mode="widthFix"></image> -->
						<view class="item_time">{{ item.createTime }}</view>
					</view>
				</view>
				<!-- @click="details(item) -->
				<view class="warp">
					<view class="text">
						<text>{{ item.text }}</text>
					</view>
				</view>

				<view class="item_img" v-if="true">
					<view class="equall-img" v-for="itep in item.medias">
						<!-- <image src="@/static/logo.png" mode="aspectFill"></image> -->
						<image :src="itep" mode="aspectFill"></image>
					</view>
				</view>

				<view class="item_bottom" v-if="false">
					<!-- <view @click.stop="like(item.id,2,item.isCollect,i)">
						<uni-icons v-if="true" type="heart-filled" size="26" color="#E83A3A"></uni-icons>
						<uni-icons v-else type="heart" size="26"></uni-icons>
						<text>{{item.collect||0}}</text>
					</view> -->
					<!-- @click.stop="like(item.id,1,item.isLike,i)" -->
					<view class="like-box">
						<uni-icons v-if="true" type="hand-up-filled" size="22" color="#FC8925"></uni-icons>
						<view class="like-list">
							<text v-for="itex in item.likeVOList">{{ itex.nickName }}</text>
						</view>
					</view>
					<!-- <view>
						<image src="@/static/img/comment.png" mode="aspectFill"></image>
						<text>{{ item.commentVOList.length }}</text>
					</view> -->

					<view></view>
				</view>
			</view>
			<!-- <view class="friend">
				<image src="@/static/img/not-icon.png" mode="widthFix"></image>
				<view class="">暂未开放</view>
			</view> -->
		</view>
	</view>
</template>

<script>
	import navBarMixin from '@/mixin/navBarMixin.js'
	import { friendCircleApi, linkFriendCircleApi } from '@/api/api.js'
	export default {
		data() {
			return {
				page: {
					pageNum: 1,
					pageSize: 10
				},
				total: '',
				firendCircleList: [],
				tabIndex: 0,
				list: ['朋友圈', '广场'],
			}
		},
		mixins: [navBarMixin],
		methods: {
			add() {
				// uni.showToast({
				// 	title:'暂未开放',
				// 	icon:'none'
				// })
				uni.navigateTo({
					url: '/pages/me/plazaAdd'
				})
			},
			my() {
				// uni.showToast({
				// 	title: '暂未开放',
				// 	icon: 'none'
				// })
				uni.navigateTo({
					url: '/pages/square/my?type=1'
				})
			},

			// 获取朋友圈列表
			async getFriendList() {
				const res = await friendCircleApi(this.page)
				if (!res.code) {
					this.total = res.data.total
					var info = this.firendCircleList
					if (this.page.pageNum == 1) {
						this.firendCircleList = res.data.records
					}else {
						this.firendCircleList = info.concat(res.data.records)
					}
					this.isAll = this.firendCircleList.length == this.total ? 0 : 1
				}
			},
			// 点赞朋友圈
			async linkDynamic(id) {
				const res = await linkFriendCircleApi(id)
			},

			tab(e) {
				if(e) {
					uni.showToast({
						title: '敬请期待',
						icon: 'none'
					})
					return
				}
				this.tabIndex = e
			},
			details(item) {
				uni.navigateTo({
					url: '/pages/square/details?itemData=' + item.id
				})
			},

		},
		onShow() {
			this.getFriendList()
		},
		onLoad() {},
		
		onReachBottom() {
			if(this.isAll) {
				this.page.pageNum++
				this.getFriendList()
			}
		}

	}
</script>

<style lang="scss" scoped>
	page {
		background: #f8f8f8;
	}

	.wf-box {
		overflow: hidden;

		.head {
			position: fixed;
			top: 0;
			z-index: 1;
			width: 100%;
			background: #fff;

			.head-np {
				display: flex;
				// justify-content: space-between;
				align-items: center;
				width: 100%;
				height: 96rpx;
				padding: 0 30rpx;
				box-shadow: 0rpx 10rpx 10rpx 0rpx rgba(50, 50, 50, 0.1);
				box-sizing: border-box;

				.add-icon {
					width: 48rpx;
					height: 48rpx;
					margin-left: 30rpx;
				}

				.tab {
					flex: 1;
					// height: 120rpx;
					display: flex;
					align-items: center;
					// justify-content: space-between;

					.tab_item {
						color: #999999;
						position: relative;
						font-size: 30rpx;
						margin-right: 40rpx;

						.t_i_text {}

						.t_i_line {
							width: 34rpx;
							height: 4rpx;
							margin: 8rpx auto 0;
							background: #3F93FF;
							border-radius: 4rpx;

						}

						.t_i_line2 {
							width: 34rpx;
							height: 4rpx;
							margin: 8rpx auto 0;
							background: #ffffff;
							border-radius: 4rpx;
						}
					}

					.tab_sel {
						font-weight: 700;
						font-size: 38rpx;
						color: #333333;
					}
				}
			}
		}

		.main {
			margin-top: 30rpx;

			.item {
				background-color: white;
				margin: 30rpx 0;
				padding: 30rpx;

				:nth-of-type(1) {

					// box-shadow: inset 20rpx 20rpx 100rpx rgba(213,213,213, 0.5);
				}
			}

			.item_top {
				display: flex;
				align-items: center;
				position: relative;
				height: 90rpx;

				>image {
					width: 90rpx;
					height: 90rpx;
					border-radius: 50%;
					margin-right: 20rpx;
				}

				.item_name {
					flex: 1;
					display: flex;
					flex-direction: column;
					// justify-content: space-around;
					height: 100%;

					view {
						&:first-child {
							font-size: 30rpx;
							// margin: 5rpx 0 14rpx 0;
							display: flex;
							align-items: center;

							image {
								width: 32rpx;
								margin-left: 10rpx;
							}
						}

						&:last-child {
							margin-top: 8rpx;
							font-size: 24rpx;
							color: #999999;
						}
					}
				}

				.del {
					height: 100%;
					display: flex;
					flex-direction: column;
					// justify-content: space-around;
					text-align: right;

					image {
						width: 72rpx;
						display: block;
						margin-left: auto;
					}
				}

				.item_time {
					font-size: 24rpx;
					color: #999999;
					// margin-top: 8rpx;
				}
			}

			.comment {
				display: flex;
				align-items: center;
				margin-top: 30rpx;
				padding-bottom: 30rpx;
				border-bottom: 1rpx solid #DDDDDD;

				image {
					width: 62rpx;
					display: block;
				}

				input {
					flex: 1;
					height: 52rpx;
					background: #F2F2F2;
					border-radius: 31rpx;
					margin-left: 20rpx;
					font-size: 26rpx;
					padding: 0 30rpx;
				}
			}

			.warp {
				// display: flex;
				font-size: 28rpx;
				margin-top: 20rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-line-clamp: 2; // 控制多行的行数
				-webkit-box-orient: vertical;

				.text {
					.switch {
						float: right;
						clear: both;
						color: #FF5E5E;
						margin-right: 10rpx;
					}

					text {
						line-height: 40rpx;
					}
				}

				.text::before {
					content: '';
					width: 0rpx;
					height: calc(100% - 35rpx);
					background-color: red;
					float: right;
				}
			}

			.item_img {
				display: flex;
				flex-wrap: wrap;
				margin-top: 5rpx;

				.equall-img {
					width: calc(100% / 3);
					margin-top: 15rpx;
					box-sizing: border-box;
					overflow: hidden;

					image {
						width: 210rpx;
						height: 198rpx;
						display: block;
						border-radius: 8rpx;
					}

					&:nth-child(3n - 1) {
						image {
							margin: 0 auto;
						}
					}

					&:nth-child(3n) {
						image {
							margin-left: auto;
						}
					}
				}

			}

			.item_bottom {
				padding-bottom: 10rpx;
				padding-top: 20rpx;
				margin-top: 30rpx;
				font-size: 28rpx;
				color: #666666;
				border-top: 2rpx solid #DDDDDD;

				.like-box {
					display: flex;

					.like-list {
						flex: 1;
						margin-left: 20rpx;

						text {
							margin-right: 12rpx;
						}
					}
				}

				image {
					width: 40rpx;
					height: 40rpx;
				}
			}

			.friend {
				height: calc(100vh - 200rpx);
				text-align: center;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;

				image {
					width: 386rpx;
					// margin-top: 50%;
				}

				view {
					font-size: 26rpx;
					color: #999999;
				}
			}
		}
	}
</style>